/*
 *  MTouchware_control_receiver.h
 *
 *  Header of MTouchware_control_receiver.c that monitors OSC messages 
 *  received with from another application and modifies the mtouchware 
 *  behaviour.
 *
 *  Copyright (C) 2010 LIMSI-CNRS (Orsay-France) and EFREI (Paris-France)
 *
 *  Authors: Rami Ajaj, Nicolas Flasque and Frederic Vernier.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as
 *  published by the Free Software Foundation; either version 2.1 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  $Id$
 */

#ifndef MTOUCHWARE_CONTROL_RECEIVER_H
#define MTOUCHWARE_CONTROL_RECEIVER_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifndef WIN32
  #include <sys/time.h>
  #include <unistd.h>
#else 
  #include <time.h>
#endif

#include "lo/lo.h"
#include "MTouchware_handlers.h"



/**
 * \defgroup MTcouchware control receiver
 *
 * Handles the reception of control messages received from another application 
 * and dispatches them to the appropriate handlers
 * @{
 */

/**
 * \brief TUIO_IN_PORT defines the UDP port that the TUIO_receiver must listen to.
 */
//char *CONTROL_IN_PORT;

/**
 * \brief Listens to OSC meesages received on port CONTROL_IN_PORT and dispatches
 * them to the appropriate handlers.
 *
 * \return An integer specifying wether if a problem has occured or not.
 *
 */
void* MTouchware_control_receiver(void * arg);

/**
 * \brief Handles any OSC control message.
 *
 * \param path char* specifying the path of the message.
 * \param types char* specifying types of arguments this message handles.
 * \param argv char** specifying the arguments of the message.
 * \param argc integer specifying the number of arguments.
 * \param data A value passed from the method that invoked this callback method.
 * \param user_data A value passed from the method that invoked this callback method.
 * \return An integer. Returning 1 means that the message has not been
 *  fully handled and the server should try other methods.
 *
 */
int generic_control_handler(const char *path, const char *types, lo_arg **argv,
		    int argc, void *data, void *user_data);


/** @} */
#ifdef __cplusplus
}
#endif

#endif
